package mtn.bowen.yan.server.enums;

/**
 * @author <a href=mailto:yanbowen90@foxmail.com> bowen.yan </a>
 * @version 1.0
 * @description: TODO
 * @date 2021-10-24 10:07 AM
 */
public enum WeekEnum {
    /*** 星期一 */
    MONDAY(1, "星期一"),
    /*** 星期二 */
    TUESDAY(2, "星期二"),
    /*** 星期三 */
    WEDNESDAY(3, "星期三"),
    /*** 星期四 */
    THURSDAY(4, "星期四"),
    /*** 星期五 */
    FRIDAY(5, "星期五"),
    /*** 星期六 */
    SATURDAY(6, "星期六"),
    /*** 星期日 */
    SUNDAY(7, "星期日"),
    /*** 未知分类 */
    UNKNOWN(99, "未知分类"),
    ;

    WeekEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static WeekEnum getWeek(String msg) {
        for (WeekEnum value : values()) {
            if (value.getMsg() == msg) {
                return value;
            }
        }
        return UNKNOWN;
    }

    public static WeekEnum getWeek(Integer code) {
        for (WeekEnum value : values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return UNKNOWN;
    }

    private Integer code;
    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
